package cn.campsg.messageboard.model;

import java.util.Date;

public class User {
    private Integer id;
    private String username;
    private String password;
    private String email;

    //存储用户的头像路径
    private String avatar;
    private Integer role; // 1: 普通用户, 2: 管理员
    private Date createdAt;

    // 1. 无参构造函数（必须有）
    public User() {}

    // 2. 全参数构造函数（含ID和创建时间，适合数据库查询、完整赋值）
    public User(Integer id, String username, String password, String email, String avatar, Integer role, Date createdAt) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.email = email;
        this.avatar = avatar;
        this.role = role;
        this.createdAt = createdAt;
    }

    // 3. 注册时用的（不含id、createdAt，role可选）
    public User(String username, String password, String email, String avatar, Integer role) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.avatar = avatar;
        this.role = role;
    }

    // 可选：再简化一个只含用户名和密码的构造
    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public User(String username, String password, String email,Integer role) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.role = role; // 默认角色为普通用户
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Integer getRole() {
        return role;
    }

    public void setRole(Integer role) {
        this.role = role;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", avatar='" + avatar + '\'' +
                ", role=" + role +
                ", createdAt=" + createdAt +
                '}';
    }


}
